<?php

namespace App\Admin\Controllers;

use App\Admin\Actions\Auction\AuctionBidRecordAction;
use App\Admin\Grid\NGrid;
use App\Models\AuctionOrderModel;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Grid\Displayers\Actions;

class AuctionOrderController extends AdminController
{
    protected $title = '拍卖订单';

    public function grid(): NGrid
    {
        $grid = new NGrid(new AuctionOrderModel);
        $grid->model()->orderByDesc('id');
        $grid->column('id', __('ID'))->sortable();
        $grid->column('serial_number', __('l.serialNumber'))->sortable();
        $grid->column('title', __('l.title'))->display(function () {
            return $this->auctionInfo->title;
        });
        $grid->column('file_id', __('l.fileId'))->display(function () {
            return fileIdToUrl($this->auctionInfo->file_id);
        })->image(config('oss.url'), 60, 60);
        $grid->actions(function (Actions $action) {
            $action->disableEdit();
            $action->disableDelete();
            $action->disableView();
            $action->add(new AuctionBidRecordAction);
        });
        $grid->disableActions(false);
        return $grid;
    }
}
